package com.jsmtr.rms.service.Report.impl;

import com.jsmtr.rms.dao.DaoService;
import com.jsmtr.rms.service.Report.IReportService;
import com.jsmtr.rms.utils.db.DbUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: cyx
 * @description:
 * @date: Created in 2019/4/4 11:11
 * @modified by:
 */
@Service("reportService")
public class ReportService implements IReportService {

    @Resource
    private DaoService dao;


    public void setDao(DaoService dao) {
        this.dao = dao;
    }

    @Override
    public Map<String, Object> queryDUserResumeAllFlowInfosPage(Integer page, Integer pagesize, List proids, List fids, Map<String,Map> prams) throws Exception {
        StringBuffer querySQL = new StringBuffer(" select * from view_duserresume vdur where 1=1 ");
        StringBuffer countSQL = new StringBuffer(" select count(*) from  VIEW_DUSERRESUME vdur where 1=1 ");
        StringBuffer condition = new StringBuffer();
        Map<String, Object> map = new HashMap<String, Object>();
        if (proids!=null&&proids.size()>0){
            condition.append(" and vdur.proid in (");
            for (Object proid : proids) {
                condition.append("'"+proid.toString()+"',");
            }
            condition.substring(0,condition.length()-1);
            condition.append(")");

        }

        if (fids!=null&&fids.size()>0){
            for (Object fid : fids) {
                condition.append(" and vdur.path like  '%/"+fid+"/%'");
               // map.put("fpathid",fid);
            }

        }
        querySQL.append(condition);
        countSQL.append(condition);

        if(prams!=null&&prams.size()>0){
            Map queryparam=prams.get("params");
            Map orderParam=prams.get("order");
        }

        return DbUtil.pageSqlQueryMap(page,pagesize,querySQL.toString(),map,countSQL.toString(),dao);
    }

    @Override
    public Map<String, Object> queryZZResumeAllFlowInfosPage(Integer page, Integer pagesize, List proids, List fids, Map<String,Map> prams) throws Exception {
        StringBuffer querySQL = new StringBuffer(" select * from view_zzuserresume vdur where 1=1 ");
        StringBuffer countSQL = new StringBuffer(" select count(*) from  view_zzuserresume vdur where 1=1 ");
        StringBuffer condition = new StringBuffer();
        Map<String, Object> map = new HashMap<String, Object>();
        if (proids!=null&&proids.size()>0){
            condition.append(" and vdur.proid in (");
            for (Object proid : proids) {
                condition.append("'"+proid.toString()+"',");
            }
            condition.substring(0,condition.length()-1);
            condition.append(")");

        }

        if (fids!=null&&fids.size()>0){
            for (Object fid : fids) {
                condition.append(" and vdur.path like '%/"+fid+"/%'");
                // map.put("fpathid",fid);
            }

        }
        querySQL.append(condition);
        countSQL.append(condition);

        if(prams!=null&&prams.size()>0){
            Map queryparam=prams.get("params");
            Map orderParam=prams.get("order");
        }

        return DbUtil.pageSqlQueryMap(page,pagesize,querySQL.toString(),map,countSQL.toString(),dao);
    }
}
